package com.ncloud.crm.mapper;

import com.ncloud.crm.entity.BsDiscnt;
import org.apache.ibatis.annotations.*;

import com.ncloud.crm.entity.BsProduct;
@Mapper
public interface BsProductMapper {
	
	@Insert("insert into bs_product(cust_id, prod_inst_id, prod_id,prod_name, begin_date, end_date, update_time, update_user, remark)"
            + " values(#{custId},#{prodInstId},#{prodId},#{prodName},#{beginDate},#{endDate},#{updateTime},#{updateUser},#{remark})")
	int insertBsProduct(BsProduct product);
	
	@Update("update bs_product set end_date=#{endDate},update_time=#{updateTime},"
			+ "update_user=#{updateUser},remark=#{remark} where prod_inst_id=#{prodInstId} and begin_date = #{beginDate}")
	int updateBsProduct(BsProduct product);
	@Select(value = { "select * from bs_product where prod_inst_id = #{prodInstId} and  now() between begin_date and end_date" })
	@Results({ @Result(column = "prod_id", property = "prodId"),@Result(column = "cust_id", property = "custId"),
			@Result(column="prod_inst_id",property="prodInstId"),@Result(column="remark",property="remark"),
			@Result(column="prod_name",property="prodName"),@Result(column="begin_date",property="beginDate"),
			@Result(column="end_date",property="endDate"),@Result(column="update_time",property="updateTime"),
			@Result(column="update_user",property="updateUser")})
	public BsProduct getBsProductByPk(Long prodInstId);
}